package demo.practice.leetcode_eveyday;

public class P1720 {

    public static void main(String[] args) {
        //Integer one = 1;
        //Integer mone = -1;

        System.out.println(~1);
        System.out.println(-1^1);
        System.out.println(Integer.toBinaryString(2));
        System.out.println(Integer.toBinaryString(-2));

        System.out.println();
    }

    public int[] decode(int[] encoded, int first) {
        //a ^ b ^ b=a

        //encoded[i] = arr[i] ^ arr[i + 1]
        //arr[i] ^ arr[i + 1]  ^ arr[i + 1]= arr[i]
        //encoded[i] ^ arr[i + 1] = arr[i]


        //encoded[i] = arr[i] ^ arr[i + 1]
        // arr[i] ^ arr[i + 1] ^ arr[i]= arr[i + 1]
        // encoded[i] ^ arr[i]= arr[i + 1]

        int[] o=new  int[encoded.length+1];
        o[0]= first;


        for (int i=0;i<encoded.length;i++) {
            o[i+1]= encoded[i]^o[i];
        }
        return o;
    }
}
